package com.wpw.dream.masteworker;

import java.util.Map;

public class MasterWordersTest {
	
	public static void main(String[] args) {
		Master master = new Master();
		MyTask task = null;
		for (long i = 1; i <= 1000; i++) {
			task = new MyTask();
			task.setI(i);
			master.addTask(task);
		}
		
		Worker worker;
		for (int i = 0; i < 2; i++) {
			worker = new Worker();
			master.addWorker(worker);
		}
		master.excute();
		Map<Object, Object> result = master.getResult();
		System.out.println("result"+result.size());
		long i = 0L;
		for (Map.Entry<Object, Object> me : result.entrySet()) {
			i = i + Long.parseLong(me.getValue().toString());
		}
		System.out.println(i);
		
	}
}

class MyTask implements Task {
	
	private Long i;
	
	public MyTask() {
		this.i = 0L;
	}
	
	@Override
	public Object handle() {
		return i * i * i;
	}
	
	public void setI(Long i) {
		this.i = i;
	}
	
}
